import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hello")
public class HelloHttp extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //先简单测试一下能否响应， 然后通过 HttpServletRequest 对象的方法，获取请求参数
//        System.out.println("HelloHttp的doGet方法被成功调用");
//        resp.setContentType("text/html; charset=utf-8");
//        resp.getWriter().write("服务器能够成功返回信息");    测试成功了
        resp.setContentType("text/html; charset=utf-8");
//        StringBuilder respBody = new StringBuilder();
//        respBody.append(req.getQueryString());
//        respBody.append(req.getMethod());
//        respBody.append(req.getProtocol());
//        resp.getWriter().write(respBody.toString());
        String name=req.getParameter("name");
        String classId=req.getParameter("classId");
        resp.getWriter().write("name: "+name+"   classId: "+classId);

    }
}
